using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace FadeJSON
{
    /// <summary>
    /// "xxx"
    /// </summary>
    public class JsonString : JsonBaseType
    {
        /// <summary>
        /// "xxx"
        /// </summary>
        private readonly string vString;

        /// <summary>
        /// "xxx"
        /// </summary>
        public override dynamic Value { get { return this.vString; } }

        #region ctor

        public JsonString(string value)
        {
            vString = value;
        }

        #endregion

        /// <summary>
        /// "xxx"
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public override bool Equals(JsonBaseType other)
        {
            var right = other as JsonString;

            return (right != null) && (this.vString == right.vString);
        }

        public static implicit operator JsonString(string value)
        {
            return new JsonString(value);
        }

        public static implicit operator string(JsonString obj)
        {
            return obj.vString;
        }

        internal override void ToString(StringBuilder builder, ref int tab)
        {
            const string quot = "\"";
            builder.Append(quot); builder.Append(vString); builder.Append(quot);
        }

    }

}